﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CoiffeurProject.DBMS.Utils
{
    internal static class FileManagment
    {
        public static String[] Load(String path)
        {
            var datas = new List<string>();

            try
            {
                using (StreamReader sr = new StreamReader(path))
                {
                    string line;

                    while ((line = sr.ReadLine()) != null && line.Length > 0) datas.Add(line);
                }
            }
            catch (Exception e)
            {
                File.Create(path);
            }

            return datas.ToArray();
        }

        public static void Save(String path, String[] data)
        {
            using (StreamWriter sw = new StreamWriter(path))
            {
                for (int i = 0; i < data.Length; i++)
                    sw.WriteLine(data[i]);
            }
        }
    }
}
